package com.txy.webmanagement.mapper;

import com.txy.webmanagement.model.SysMenu;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper

public interface SysMenuMapper  {

    @Select("select id , menu_name menuName, icon_style iconStyle ,parent_id parentId,http_url httpUrl, rows,enable,create_time createTime " +
            " from sys_menu where enable=1 and menu_name  like '% ${menuName}%' ")
    List<SysMenu> findPageList(@Param("menuName") String menuName);

    @Select("<script>  select m.id,m.menu_name  menuName,m.icon_style iconStyle,m.parent_id parentId,m.http_url httpUrl,m.rows,m.enable,m.create_time createTime" +
            " from sys_permissions  p join sys_menu m on p.menu_id=m.id where m.enable=1 and IFNULL(m.parent_id,'')='0' and p.user_type_id= #{userTypeId} order by m.rows asc </script>")
    List<SysMenu> findFirstList(@Param("userTypeId") String userTypeId);

    @Select("select m.id,m.menu_name menuName,m.parent_id parentId,m.rows,m.enable,m.create_time createTime,m.icon_style iconStyle,m.http_url as httpUrl " +
            " from sys_permissions  p join sys_menu m on p.menu_id=m.id where m.enable=1 and p.user_type_id= #{userTypeId} and m.parent_id= #{parentId} order by m.rows asc ")
    List<SysMenu> findSecondByUserTypeIdAndParentId(@Param("userTypeId") String userTypeId, @Param("parentId") String parentId);

}
